package cn.itcast.crm.service;



import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.itcast.crm.dao.CustomerRepository;
import cn.itcast.crm.domain.Customer;

@Service
@Transactional
public class CustomerServiceImpl implements ICustomerService {

	// 注入DAO
	@Autowired
	private CustomerRepository customerRepository;

	

	@Override
	public void save(Customer customer) {
		// TODO Auto-generated method stub
		 customerRepository.save(customer);
	}

	@Override
	public void deleteUser(Integer abc) {
		// TODO Auto-generated method stub
		customerRepository.delete(abc);
		
	}

	@Override
	public List<Customer> findUser() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void update(Customer customer) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public List<Customer> findUserById(Integer a) {
		// TODO Auto-generated method stub
		return null;
	}
	
	
	

	@Override
	public List<Customer> findCustomerIsNull() {
		// TODO Auto-generated method stub
		return customerRepository.findByfixedAreaIdIsNull();
	}

	

	@Override
	public List<Customer> findCustomerByfixedAreaId(String fixedAreaId) {
		
		return customerRepository.findByfixedAreaId(fixedAreaId);
	}

	@Override
	public void updateCustomer(String CustomerIds, String fixedAreaId) {
		customerRepository.clearFixedAreaId(fixedAreaId);
		System.out.println(123+"周永健");
		if(StringUtils.isBlank(CustomerIds)){
			return;
		}
		String[] split = CustomerIds.split(",");
		for (String string : split) {
			
			int int1 = Integer.parseInt(string);
			customerRepository.updatefixedAreaId(fixedAreaId,int1);
		}
		
		
	}

/*	@Override
	public void removeCustomer(String fixedAreaId) {
		customerRepository.removefixedAreaId(fixedAreaId);
		
	}*/

}
